forcecell 2.2.0
Loading...
Searching...
No Matches
Force Cell Click Driver

API for configuring and manipulating Force Cell Click driver. More...

Topics

 Force Cell Settings
 Settings of Force Cell Click driver.
 Force Cell MikroBUS Map
 MikroBUS pin mapping of Force Cell Click driver.

Functions

void forcecell_cfg_setup (forcecell_cfg_t *cfg)
 Force Cell configuration object setup function.
void forcecell_drv_interface_sel (forcecell_cfg_t *cfg, forcecell_drv_t drv_sel)
 Force Cell driver interface setup function.
err_t forcecell_init (forcecell_t *ctx, forcecell_cfg_t *cfg)
 Force Cell initialization function.
err_t forcecell_read_raw_adc (forcecell_t *ctx, uint16_t *raw_adc)
 Force Cell read raw ADC value function.
err_t forcecell_read_voltage (forcecell_t *ctx, float *voltage)
 Force Cell read voltage level function.
err_t forcecell_read_voltage_avg (forcecell_t *ctx, uint16_t num_conv, float *voltage_avg)
 Force Cell read average voltage level function.
err_t forcecell_set_vref (forcecell_t *ctx, float vref)
 Force Cell set vref function.
err_t forcecell_calib_offset (forcecell_t *ctx)
 Force Cell calib offset function.
err_t forcecell_read_force (forcecell_t *ctx, float *force)
 Force Cell read force function.

Detailed Description

API for configuring and manipulating Force Cell Click driver.

Any initialization code needed for MCU to function properly. Do not remove this line or clock might not be set correctly.

Function Documentation

◆ forcecell_calib_offset()

err_t forcecell_calib_offset ( forcecell_t * ctx)

Force Cell calib offset function.

This function calibrates the zero force offset value.

Parameters
[in]ctx: Click context object. See forcecell_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
This function should only be called when no force is applied to the sensor.

◆ forcecell_cfg_setup()

void forcecell_cfg_setup ( forcecell_cfg_t * cfg)

Force Cell configuration object setup function.

This function initializes Click configuration structure to initial values.

Parameters
[out]cfg: Click configuration structure. See forcecell_cfg_t object definition for detailed explanation.
Returns
Nothing.
Note
The all used pins will be set to unconnected state.

◆ forcecell_drv_interface_sel()

void forcecell_drv_interface_sel ( forcecell_cfg_t * cfg,
forcecell_drv_t drv_sel )

Force Cell driver interface setup function.

This function sets a serial driver interface which will be used further in the Click driver.

Parameters
[out]cfg: Click configuration structure. See forcecell_cfg_t object definition for detailed explanation.
[in]drv_sel: Driver interface selection. See forcecell_drv_t object definition for detailed explanation.
Returns
Nothing.
Note
This driver selection should be called before init function to configure the driver to work with the serial interface which is consistent with the real state of the hardware. If this function is not called, the default driver interface will be set.

◆ forcecell_init()

err_t forcecell_init ( forcecell_t * ctx,
forcecell_cfg_t * cfg )

Force Cell initialization function.

This function initializes all necessary pins and peripherals used for this Click board.

Parameters
[out]ctx: Click context object. See forcecell_t object definition for detailed explanation.
[in]cfg: Click configuration structure. See forcecell_cfg_t object definition for detailed explanation.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ forcecell_read_force()

err_t forcecell_read_force ( forcecell_t * ctx,
float * force )

Force Cell read force function.

This function reads the applied force level [N].

Parameters
[in]ctx: Click context object. See forcecell_t object definition for detailed explanation.
[out]force: Applied force level [N].
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
This function relies on calibrated zero force offset. Refer to forcecell_calib_offset functions.

◆ forcecell_read_raw_adc()

err_t forcecell_read_raw_adc ( forcecell_t * ctx,
uint16_t * raw_adc )

Force Cell read raw ADC value function.

This function reads raw ADC value.

Parameters
[in]ctx: Click context object. See forcecell_t object definition for detailed explanation.
[out]raw_adc: Output ADC result.
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
None.

◆ forcecell_read_voltage()

err_t forcecell_read_voltage ( forcecell_t * ctx,
float * voltage )

Force Cell read voltage level function.

This function reads raw ADC value and converts it to proportional voltage level.

Parameters
[in]ctx: Click context object. See forcecell_t object definition for detailed explanation.
[out]voltage: Output voltage level [V].
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
The conversion to voltage depends on the entered reference voltage.

◆ forcecell_read_voltage_avg()

err_t forcecell_read_voltage_avg ( forcecell_t * ctx,
uint16_t num_conv,
float * voltage_avg )

Force Cell read average voltage level function.

This function reads a desired number of ADC samples and calculates the average voltage level.

Parameters
[in]ctx: Click context object. See forcecell_t object definition for detailed explanation.
[in]num_conv: Number of ADC samples.
[out]voltage_avg: Average output voltage level [V].
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
The conversion to voltage depends on the entered reference voltage.

◆ forcecell_set_vref()

err_t forcecell_set_vref ( forcecell_t * ctx,
float vref )

Force Cell set vref function.

This function sets the voltage reference for Force Cell Click driver.

Parameters
[in]ctx: Click context object. See forcecell_t object definition for detailed explanation.
[in]vref: Reference voltage (volts).
Returns
  • 0 - Success,
  • -1 - Error. See #err_t definition for detailed explanation.
Note
The default voltage reference set with forcecell_init is 3.3V.